<template>
    <div >
        <div v-if="(inputType=='custDic'||inputType=='dic')" >
            <CommonType :emit-validate="true" @validateExpress="validateExpress" :is-in-opt="true" @calexp="handle"  :atomKey="atomKey" :inputConfig="inputConfig" :inputType="inputType" :valueIndex="0" :valueNames="valueNames" :values="values"/>
        </div>
        <div v-else-if="inputType==='component'">
            <CommonType :emit-validate="true" @validateExpress="validateExpress" :is-in-opt="true" @calexp="handle"  :atomKey="atomKey" :inputConfig="inputConfig" :inputType="inputType" :valueIndex="0" :valueNames="valueNames" :values="values"/>
        </div>
        <div v-else>
            <div  style="float: left;font-weight: bold">(&nbsp;</div>
                <div style="float: left;" v-for="(item,itemIndex) in values">
                    <CommonType :emit-validate="true" @validateExpress="validateExpress" :is-in-opt="true" @calexp="handle"  :atomKey="atomKey" :inputConfig="inputConfig" :inputType="inputType" :valueIndex="itemIndex" :valueNames="valueNames" :values="values"/>
                    <Icon type="ios-trash-outline" color="red" size="16" @click="deleteValue(itemIndex)"/>,&nbsp;
                </div>
            <div style="float: left;font-weight: bold">
                <Icon type="md-add" color="#2d8cf0 " @click="addValue" />&nbsp;)&nbsp;
            </div>
        </div>
    </div>
</template>
<style lang="less" scoped>
</style>
<script>
    import ruiMixin from "_c/rui-auto/rui-rules/src/mixin/rule-mixin";
    import CommonType from "_c/rui-auto/rui-rules/src/component/express/CommonType";
    export default {
        name: 'in-type',
        components:{
            'CommonType':CommonType
        },
        mixins: [ruiMixin],
        props: {
            atomKey:{
                type:String,
                require: true
            },
            values: {
                type: Array,
                require:true
            },
            valueNames: {
                type: Array,
                require:true
            },
            inputType:{
                type:String,
                require: true
            },
            inputConfig:{
                type:Object,
                require:true
            }
        },
        data() {
            return {
                validate:false
            }
        },
        methods:{
            addValue(){
                if(this.inputType=='number'){
                    this.values.push(0);
                }else if(this.inputType=='cascader'){
                    this.values.push([]);
                }else{
                    this.values.push('');
                }
                this.valueNames.push('');
            },
            deleteValue(itemIndex){
                this.values.splice(itemIndex,1);
                this.valueNames.splice(itemIndex,1);
            },
            validateExpress(validate){
                this.validate = validate;
            },
            handle() {
                this.$emit('calexp');
            },
        }
    }
</script>
